Login
www.borland.com
Borland Developer Community Home
Community Home > Delphi

Borland Developer Support   


Retrieving a list of installed Applications on Windows - by Borland Developer Support Staff

Abstract: How to get a listing of all installed applications on a machine running Windows OS

Here is a method for retrieving a list of installed applications on a particular machine running a Windows OS.



1. Start up Delphi.

2. Select File | New Application.

3. Add Registry to the uses of your new Unit.

4. Place a TListBox (ListBox1) component on your form.

5. Place a TButton (Button1) in your form.

6. Place the following code in the OnClick event of the Button1:

procedure TForm1.Button1Click(Sender: TObject);
const
  REGKEYAPPS = '\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall';

var
  reg    : TRegistry;
  List1  : TStringList;
  List2  : TStringList;
  i, n   : integer;

begin
  reg    := TRegistry.Create;
  List1  := TStringList.Create;
  List2  := TStringList.Create;

  {Load all the subkeys}
  with reg do
  begin
    RootKey := HKEY_LOCAL_MACHINE;
    OpenKey(REGKEYAPPS, false);
    GetKeyNames(List1);
  end;
 {Load all the Value Names}
  for i := 0 to List1.Count -1 do
  begin
    reg.OpenKey(REGKEYAPPS + '' + List1.Strings[i],false);
    reg.GetValueNames(List2);

    {We will show only if there is 'DisplayName'}
    n := List2.IndexOf('DisplayName');
    if (n <> -1) and (List2.IndexOf('UninstallString') <> -1) then
    begin
      ListBox1.Items.Add((reg.ReadString(List2.Strings[n])));
    end;
  end;
  List.Free;
  List2.Free;
  reg.CloseKey;
  reg.Destroy;
end;


Add or View comments on this article

Products:
Borland Delphi 5.x

Platforms:
Windows 2000 1.0; Windows 98 1.0; Windows NT 4.0 SP5

Article ID: 27953   Publish Date: October 30, 2001  Last Modified: November 01, 2001

Communities

AppServer  |  C++  |  CORBA  |  Delphi  |  InterBase  |  Java  |  Linux

Books |  Chat |  Code Central |  Downloads |  Feedback
Help |  Home Pages |  Museum |  Newsgroups |  Shopping